package de.doegel.common.util;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;

import android.util.Log;

public abstract class Util
{

	public static String ConvertToUT8( String text )
	{
		String url = text;
		Charset charsetDestino = Charset.forName("ISO-8859-16");
		CharsetDecoder decoderDestino = charsetDestino.newDecoder();
		Charset charsetOrigem = Charset.forName("ISO-8859-16");
		CharsetEncoder encoderOrigem = charsetOrigem.newEncoder();
		try
		{
			ByteBuffer bbuf = encoderOrigem.encode(CharBuffer.wrap(url));
			CharBuffer cbuf = decoderDestino.decode(bbuf);
			url = cbuf.toString();
			Log.d("username", url);
		}
		catch (CharacterCodingException e)
		{
			e.printStackTrace();
		}
		return url;
	}
}
